// 弹出全屏黑色背景
$("#click-timer-add").live('click', function() {
	$("html").prepend("<div class='quanping' ></div>");
	$(".quanping").height($(document).height());

	$(".timer-frame").fadeIn("slow");
	
	timerInit();
});

// 确定
$(".timer-submit").click(function() {
	var h = $("#timer-hour").val();
	var m = $("#timer-minu").val();
	var s = $("#timer-seco").val();
	
	exTimerH=h;
	exTimerM=m;
	exTimerS=s;
	
	$(".timer-frame").fadeOut("slow");
	$(".quanping").remove();
	
	if(exTimerH==0 && exTimerM==0 && exTimerS==0){
		$("#click-timer-add").attr("title","计时器未设定");
	}
	else{
		$("#click-timer-add").attr("title",exTimerH+"小时 "+exTimerM+"分 "+exTimerS+"秒");
	}
	
});

/**
 * 关闭计时器
 */
$(".timer-close").click(function() {
	exTimerH=0;
	exTimerM=0;
	exTimerS=0;
	
	$(".timer-frame").fadeOut("slow");
	$(".quanping").remove();
	
	$("#click-timer-add").attr("title","计时器未设定");
});

/**
 * 关闭属性框
 */
$(".timer-cancel,.border-close").click(function() {

	$(".timer-frame").fadeOut("slow");
	$(".quanping").remove();

});


/**
 * 初始化
 */
function timerInit() {

	var hourhtml = "<select id='timer-hour' name='timer-hour'>"
			+ "<option value='0' checked>0</option>";
	for ( var i = 1; i < 24; i++) {
		hourhtml += "<option value='" + i + "'>" + i + "</option>";
	}
	hourhtml += "</select>小时";

	var minuhtml = "<select id='timer-minu' name='timer-minu'>"
			+ "<option value='0' checked>0</option>";
	for ( var i = 1; i < 60; i++) {
		minuhtml += "<option value='" + i + "'>" + i + "</option>";
	}
	minuhtml += "</select>分钟";

	var secondhtml = "<select id='timer-seco' name='timer-seco'>"
			+ "<option value='0' checked>0</option>";
	for ( var i = 1; i < 60; i++) {
		secondhtml += "<option value='" + i + "'>" + i + "</option>";
	}
	secondhtml += "</select>秒";

	$("#timer-duration").html(
			"本项目持续时间:<p>" + hourhtml + minuhtml + secondhtml);
	
	$("#timer-hour").val(exTimerH);
	$("#timer-minu").val(exTimerM);
	$("#timer-seco").val(exTimerS);

}
